/*p7P7SgL+KDNDWvTc0+Tff7/kmskou3OvZVcsKCAxIrQ1Iz713hF9KX6LzTvpLt/l*/
import { renderSelectField } from '../publicMethods/pubUtils';

/**
 * 应收核销，本方核销对象编辑后事件
 * @param {*} props 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 */
function jf_hxdxCBox_AfterEvent(that, props, value, cytjCode, bfCode, dfCode) {
    let meta = props.meta.getMeta()
    if (value.value == 'gys') {
        meta[bfCode].items.map((item) => {
            if (item.attrcode == 'jf_dxmcRef') {
                item.itemtype = 'refer'
                item.refName = that.state.json['verificationsheet-000039']/* 国际化处理： 供应商档案*/
                item.refcode = 'uapbd/refer/supplier/SupplierRefTreeGridRef/index'
                item.queryCondition = () => {
                    return {
                        DataPowerOperationCode: 'fi',//使用权组
                        isDataPowerEnable: 'Y',
                        pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                    }
                }
            }
            return item;
        })
        meta[dfCode].items.map((item) => {
            if (item.attrcode == 'df_dxmcRef') {
                item.itemtype = 'refer'
                item.refName = that.state.json['verificationsheet-000038']/* 国际化处理： 客户档案*/
                item.refcode = 'uapbd/refer/customer/CustomerDefaultTreeGridRef/index'
                item.queryCondition = () => {
                    return {
                        DataPowerOperationCode: 'fi',//使用权组
                        isDataPowerEnable: 'Y',
                        pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                    }
                }
            }
            return item;
        })
        renderSelectField(that, props, bfCode, 'jfBillTypeBox', ['khys', 'gysfk'])
        renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys'])
        renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])

        props.form.setFormItemsValue(cytjCode, { 'jf_dxmcRef': { value: null, display: null } });
        props.form.setFormItemsValue(cytjCode, { 'df_dxmcRef': { value: null, display: null } });
    }
    if (value.value == 'kh' || value.value == 'bm' || value.value == 'ywy') {
        if (value.value == 'kh') {
            meta[bfCode].items.map((item) => {
                if (item.attrcode == 'jf_dxmcRef') {
                    item.itemtype = 'refer'
                    item.refName = that.state.json['verificationsheet-000038']/* 国际化处理： 客户档案*/
                    item.refcode = 'uapbd/refer/customer/CustomerDefaultTreeGridRef/index'
                    item.queryCondition = () => {
                        return {
                            DataPowerOperationCode: 'fi',//使用权组
                            isDataPowerEnable: 'Y',
                            pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                        }
                    }
                }

                return item;
            })
            renderSelectField(that, props, bfCode, 'jfBillTypeBox', ['khys', 'gysfk'])
            renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys', 'bm', 'ywy'])
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])
        } else if (value.value == 'bm') {
            meta[bfCode].items.map((item) => {
                if (item.attrcode == 'jf_dxmcRef') {
                    item.itemtype = 'refer'
                    item.refName = that.state.json['verificationsheet-000002']/* 国际化处理： 部门*/
                    item.refcode = 'uapbd/refer/org/DeptTreeRef/index'
                    item.isShowUnit = true,
                        item.unitCondition = () => {
                            return {
                                pkOrgs: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                                TreeRefActionExt: 'nccloud.web.arap.ref.before.OrgSqlBuilder'
                            }
                        }
                    item.queryCondition = () => {
                        return {
                            DataPowerOperationCode: 'fi',//使用权组
                            isDataPowerEnable: 'Y',
                            busifuncode: 'all',
                            pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                        }
                    }
                }
                return item;
            })
            renderSelectField(that, props, bfCode, 'jfBillTypeBox', ['khys'])
            renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys', 'bm', 'ywy'])
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
        } else if (value.value == 'ywy') {
            meta[bfCode].items.map((item) => {
                if (item.attrcode == 'jf_dxmcRef') {
                    item.itemtype = 'refer'
                    item.refName = that.state.json['verificationsheet-000042']/* 国际化处理： 人员*/
                    item.refcode = 'uapbd/refer/psninfo/PsndocTreeGridRef/index'
                    item.isShowUnit = true,
                        item.unitCondition = () => {
                            return {
                                pkOrgs: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                                TreeRefActionExt: 'nccloud.web.arap.ref.before.OrgSqlBuilder'
                            }
                        }
                    item.queryCondition = () => {
                        return {
                            DataPowerOperationCode: 'fi',//使用权组
                            isDataPowerEnable: 'Y',
                            busifuncode: 'all',
                            pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                            pk_dept: props.form.getFormItemsValue(cytjCode, 'deptRef').value ? props.form.getFormItemsValue(cytjCode, 'deptRef').value : null
                        }
                    }
                }
                return item;
            })
            renderSelectField(that, props, bfCode, 'jfBillTypeBox', ['khys'])
            renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys', 'bm', 'ywy'])
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
        }
        props.form.setFormItemsValue(cytjCode, { 'jf_dxmcRef': { value: null, display: null } });
        props.form.setFormItemsValue(cytjCode, { 'df_dxmcRef': { value: null, display: null } });
    }
    props.renderItem('form', bfCode, 'jf_dxmcRef', null);
    props.renderItem('form', dfCode, 'df_dxmcRef', null);
}

/**
 * 应收核销，本方单据类型编辑后事件
 * @param {*} props 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 */
function jfBillTypeBox_AfterEvent(that, props, value, cytjCode, bfCode, dfCode) {
    let jfhxdx = props.form.getFormItemsValue(cytjCode, 'jf_hxdxCBox').value
    let dfhxdx = props.form.getFormItemsValue(cytjCode, 'df_hxdxCBox').value
    if (jfhxdx == 'kh') {
        if (value.value == 'gysfk') {
            renderSelectField(that, props, dfCode, 'df_hxdxCBox', ['kh', 'gys'])
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
        } else if (value.value == 'khys') {
            if (dfhxdx == 'gys') {
                renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
            }
        }
    }
    if (jfhxdx == 'gys' && dfhxdx == 'kh') {
        if (value.value == 'khys') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf'])
        } else if (value.value == 'gysfk') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
        }
    }
}

/**
 * 应收核销，对方核销对象编辑后事件
 * @param {*} props 
 * @param {*} cytjCode 
 * @param {*} bfCode 
 * @param {*} dfCode 
 */
function df_hxdxCBox_AfterEvent(that, props, value, cytjCode, bfCode, dfCode) {
    let jfhxdx = props.form.getFormItemsValue(cytjCode, 'jf_hxdxCBox').value
    let jfBilltype = props.form.getFormItemsValue(cytjCode, 'jfBillTypeBox').value
    let meta = props.meta.getMeta()
    if (value.value == 'gys') {
        meta[dfCode].items.map((item) => {
            if (item.attrcode == 'df_dxmcRef') {
                item.itemtype = 'refer'
                item.refName = that.state.json['verificationsheet-000039']/* 国际化处理： 供应商档案*/
                item.refcode = 'uapbd/refer/supplier/SupplierRefTreeGridRef/index'
                item.queryCondition = () => {
                    return {
                        DataPowerOperationCode: 'fi',//使用权组
                        isDataPowerEnable: 'Y',
                        pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                    }
                }
            }
            return item;
        })
        meta[bfCode].items.map((item) => {
            if (item.attrcode == 'jf_dxmcRef') {
                item.itemtype = 'refer'
                item.refName = that.state.json['verificationsheet-000038']/* 国际化处理： 客户档案*/
                item.refcode = 'uapbd/refer/customer/CustomerDefaultTreeGridRef/index'
                item.queryCondition = () => {
                    return {
                        DataPowerOperationCode: 'fi',//使用权组
                        isDataPowerEnable: 'Y',
                        pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                    }
                }
            }
            return item;
        })
        if (jfhxdx == 'kh' && jfBilltype == 'khys') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf', 'khsk'])
        } else if (jfhxdx == 'kh' && jfBilltype == 'gysfk') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
        } else if (jfhxdx == 'gys' && jfBilltype == 'khys') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])
        } else if (jfhxdx == 'gys' && jfBilltype == 'gysfk') {
            renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
        } else {
            props.form.setFormItemsValue(cytjCode, { 'jf_hxdxCBox': { value: 'kh', display: that.state.json['verificationsheet-000000'] } });/* 国际化处理： 客户*/
            props.form.setFormItemsDisabled(cytjCode, { jf_hxdxCBox: true });
        }
        if(jfhxdx!=value.value){
            props.form.setFormItemsValue(cytjCode, { 'df_dxmcRef': { value: null, display: null } });
            props.form.setFormItemsValue(cytjCode, { 'jf_dxmcRef': { value: null, display: null } });
        }
    }
    if (value.value == 'kh' || value.value == 'bm' || value.value == 'ywy') {
        if (value.value == 'kh') {
            meta[dfCode].items.map((item) => {
                if (item.attrcode == 'df_dxmcRef') {
                    item.itemtype = 'refer'
                    item.refName = that.state.json['verificationsheet-000038']/* 国际化处理： 客户档案*/
                    item.refcode = 'uapbd/refer/customer/CustomerDefaultTreeGridRef/index'
                    item.queryCondition = () => {
                        return {
                            DataPowerOperationCode: 'fi',//使用权组
                            isDataPowerEnable: 'Y',
                            pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                        }
                    }
                }

                return item;
            })
            if (jfhxdx == 'kh') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['gysyf', 'khsk'])
                } else if (jfBilltype == 'gysfk') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            } else if (jfhxdx == 'gys') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk', 'gysyf'])
                } else if (jfBilltype == 'gysfk') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            } else if (jfhxdx == 'bm') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            } else if (jfhxdx == 'ywy') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            }
        } else if (value.value == 'bm') {
            meta[dfCode].items.map((item) => {
                if (item.attrcode == 'df_dxmcRef') {
                    item.itemtype = 'refer'
                    item.refName = that.state.json['verificationsheet-000002']/* 国际化处理： 部门*/
                    item.refcode = 'uapbd/refer/org/DeptTreeRef/index'
                    item.isShowUnit = true,
                        item.unitCondition = () => {
                            return {
                                pkOrgs: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                                TreeRefActionExt: 'nccloud.web.arap.ref.before.OrgSqlBuilder'
                            }
                        }
                    item.queryCondition = () => {
                        return {
                            DataPowerOperationCode: 'fi',//使用权组
                            isDataPowerEnable: 'Y',
                            busifuncode: 'all',
                            pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                        }
                    }
                }

                return item;
            })
            if (jfhxdx == 'kh') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            } else if (jfhxdx == 'bm') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            } else if (jfhxdx == 'ywy') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            }
        } else if (value.value == 'ywy') {
            meta[dfCode].items.map((item) => {
                if (item.attrcode == 'df_dxmcRef') {
                    item.itemtype = 'refer'
                    item.refName = that.state.json['verificationsheet-000042']/* 国际化处理： 人员*/
                    item.refcode = 'uapbd/refer/psninfo/PsndocTreeGridRef/index'
                    item.isShowUnit = true,
                        item.unitCondition = () => {
                            return {
                                pkOrgs: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                                TreeRefActionExt: 'nccloud.web.arap.ref.before.OrgSqlBuilder'
                            }
                        }
                    item.queryCondition = () => {
                        return {
                            DataPowerOperationCode: 'fi',//使用权组
                            isDataPowerEnable: 'Y',
                            busifuncode: 'all',
                            pk_org: props.form.getFormItemsValue(cytjCode, 'pk_org').value ? props.form.getFormItemsValue(cytjCode, 'pk_org').value : null,
                            pk_dept: props.form.getFormItemsValue(cytjCode, 'deptRef').value ? props.form.getFormItemsValue(cytjCode, 'deptRef').value : null
                        }
                    }
                }
                return item;
            })
            if (jfhxdx == 'kh') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            } else if (jfhxdx == 'bm') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            } else if (jfhxdx == 'ywy') {
                if (jfBilltype == 'khys') {
                    renderSelectField(that, props, dfCode, 'dfBillTypeBox', ['khsk'])
                }
            }
        }
        props.form.setFormItemsValue(cytjCode, { 'dfBillTypeBox': { value: 'khsk', display: that.state.json['verificationsheet-000044'] } });/* 国际化处理： 收款单*/
        if(jfhxdx!=value.value){
            props.form.setFormItemsValue(cytjCode, { 'df_dxmcRef': { value: null, display: null } });
            props.form.setFormItemsValue(cytjCode, { 'jf_dxmcRef': { value: null, display: null } });
        }
    }
    //重新渲染对方对象名称
    props.renderItem('form', bfCode, 'jf_dxmcRef', null);
    props.renderItem('form', dfCode, 'df_dxmcRef', null);
}

export { jf_hxdxCBox_AfterEvent, jfBillTypeBox_AfterEvent, df_hxdxCBox_AfterEvent }
/*p7P7SgL+KDNDWvTc0+Tff7/kmskou3OvZVcsKCAxIrQ1Iz713hF9KX6LzTvpLt/l*/